﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using DataAccessLayer;

namespace ServiceLayer.Entity
{
    [DataContract]
    public class RequisitionW
    {
        int reqID;
        string reqDate;
        int requestedBy;
        string approvalDate;
        int approvalBy;
        string approvalStatus;

        [DataMember]
        public int ReqID
        {
            get { return reqID; }
            set { reqID = value; }
        }

        [DataMember]
        public string ReqDate
        {
            get { return reqDate; }
            set { reqDate = value; }
        }

        [DataMember]
        public int RequestedBy
        {
            get { return requestedBy; }
            set { requestedBy = value; }
        }

        [DataMember]
        public string ApprovalDate
        {
            get { return approvalDate; }
            set { approvalDate = value; }
        }

        [DataMember]
        public int ApprovalBy
        {
            get { return approvalBy; }
            set { approvalBy = value; }
        }

        [DataMember]
        public string ApprovalStatus
        {
            get { return approvalStatus; }
            set { approvalStatus = value; }
        }

        public static RequisitionW convert(Requisition requisition)
        {
            RequisitionW u = new RequisitionW();
            
            u.ReqID = requisition.ReqID;
            u.ReqDate = requisition.ReqDate.GetValueOrDefault().ToString();
            u.RequestedBy = requisition.RequestedBy.GetValueOrDefault();
            u.ApprovalDate = requisition.ApprovalDate.GetValueOrDefault().ToString();
            u.ApprovalBy = requisition.ApprovalBy.GetValueOrDefault();
            u.ApprovalStatus = requisition.ApprovalStatus;
           
            return u;
        }

        public static List<RequisitionW> convertList(List<Requisition> list)
        {
            List<RequisitionW> listW = new List<RequisitionW>();

            foreach (Requisition x in list)
            {
                listW.Add(convert(x));
            }
            return listW;
        }
    }
}